home *** CD-ROM | disk | FTP | other *** search
/ The Canadian & World Encyclopedia 1998 / The Canadian & World Encyclopedia 1998 - Disc 2.iso / pc / pb / profile.dir / 00175_Script_Media Wrapper Script < prev    next >
Text File  |  1997-07-29  |  13KB  |  310 lines

  1. -- Media Wrapper Handlers by kevin fraser ⌐1995 Gerri Sinclair & SFU ExCITE Centre
  2. -- v.02
  3. -- each can be any sprite, but requires list of 8 wrapper sprites to be ordered like this:
  4. -- [1:tlc, 2:ts, 3:trc, 4:rs, 5:brc, 6:bs, 7:blc, 8:ls, 9:]
  5. -- sprites ordered this way are processed in this order: [2,6,1,3,5,7,8,4]
  6.  
  7.  
  8. on more_pop md_sp, direction, wrapperSpritesList
  9.   set old_rect = the rect of sprite md_sp
  10.   
  11.   
  12.   set sp_s1 = getat(wrapperSpritesList,1)  -- side 1 right
  13.   set sp_c1 = getat(wrapperSpritesList,2) -- corner 1 right
  14.   set sp_md = getat(wrapperSpritesList,3)  -- main delta side
  15.   set sp_c2 = getat(wrapperSpritesList,4) -- corner 2 left
  16.   set sp_s2 = getat(wrapperSpritesList,5)  -- side 2 left
  17.   set sh_txt = getat(wrapperSpritesList,6) -- text cast
  18.   set sh_pan = getat(wrapperSpritesList,7) -- panel bottom
  19.   set sh_cp = getat(wrapperSpritesList,8) -- copy button
  20.   set sh_pr = getat(wrapperSpritesList,9) -- print button
  21.   set sh_arc = getat(wrapperSpritesList,10) -- archive button
  22.   
  23.   if direction = "down" then
  24.     set delta = 120 -- fudge a resize
  25.     
  26.     
  27.     place_box_contents("in",md_sp,sh_txt,sh_pan,sh_cp,sh_pr,sh_arc,sp_md,sp_s2,sp_s1,delta)
  28.     do_vertical(delta,sp_s1,sp_c1,sp_md,sp_c2,sp_s2)
  29.     see_sprite([38,39,40,41,42],true)
  30.   end if
  31.   
  32.   if direction = "up" then
  33.     set delta = -120
  34.     do_vertical(delta,sp_s1,sp_c1,sp_md,sp_c2,sp_s2)
  35.     --    place_box_contents("out",md_sp,sh_txt,sh_pan,sh_cp,sh_pr,sh_arc,sp_md,sp_s2,sp_s1,delta)
  36.     see_sprite([38,39,40,41,42],false)
  37.   end if
  38.   
  39.   
  40. end
  41.  
  42. on box_sprites_on sh_txt,sh_pan,sh_cp,sh_pr
  43.   puppetsprite sh_txt,true
  44.   puppetsprite sh_pan,true
  45.   puppetsprite sh_cp,true
  46.   puppetsprite sh_pr,true
  47.   --  puppetsprite sh_arc,true
  48.   
  49. end
  50.  
  51. on box_sprites_off sh_txt,sh_pan,sh_cp,sh_pr
  52.   puppetsprite sh_txt,false
  53.   puppetsprite sh_pan,false
  54.   puppetsprite sh_cp,false
  55.   puppetsprite sh_pr,false
  56.   --  puppetsprite sh_arc,false
  57.   
  58. end
  59.  
  60. on place_box_contents state, md_sp, sh_txt, sh_pan, sh_cp, sh_pr, sh_arc, sp_md, sp_s2, sp_s1, delta
  61.   if state = "in" then 
  62.     
  63.     box_sprites_on(sh_txt,sh_pan,sh_cp,sh_pr)
  64.     set the_top = the bottom of the rect of sprite sp_md - the height of sprite sp_md
  65.     set the_left = the left of the rect of sprite sp_s2 + the width of sprite sp_s2
  66.     set the_right = the right of the rect of sprite sp_s1 - the width of sprite sp_s1
  67.     set the_bottom = the_top + delta
  68.     
  69.     set the locv of sprite sh_txt = the_top
  70.     set the loch of sprite sh_txt = the_left
  71.     
  72.     spritebox sh_pan, the_left, the_bottom - 24, the_right, the_bottom
  73.     set the_center = the left of the rect of sprite sp_md + the width of sprite md_sp / 2
  74.     
  75.     --    put the rect of sprite md_sp && the_center
  76.     spritebox sh_cp, the_center - 25, the_bottom - 3, the_center - 25 + the width of sprite sh_cp, the_bottom - 3 - the height of sprite sh_cp
  77.     spritebox sh_pr, the_center + 5, the_bottom - 3, the_center + 5 + the width of sprite sh_pr, the_bottom - 3 - the height of sprite sh_pr
  78.     
  79.     --    spritebox sh_arc, the_left + 70, the_bottom - 3, the_left + 70 + the width of sprite sh_arc, the_bottom - 3 - the height of sprite sh_arc
  80.     
  81.   else
  82.     box_sprites_off(sh_txt,sh_pan,sh_cp,sh_pr)
  83.   end if
  84.   
  85. end
  86.  
  87. on do_vertical delta, sp_rs, sp_brc, sp_bs, sp_blc, sp_ls
  88.   
  89.   set the locv of sprite sp_bs = the locv of sprite sp_bs + delta
  90.   set the locv of sprite sp_brc = the locv of sprite sp_brc + delta
  91.   set the locv of sprite sp_blc = the locv of sprite sp_blc + delta
  92.   
  93.   spriteBox sp_rs, the left of the rect of sprite sp_rs, the top of the rect of  sprite sp_rs,the right of the rect of  sprite sp_rs, the bottom of the rect of sprite sp_rs + delta
  94.   spriteBox sp_ls, the left of the rect of sprite sp_ls, the top of the rect of sprite sp_ls,the right of the rect of  sprite sp_ls, the bottom of the rect of sprite sp_ls + delta
  95.   
  96.   
  97.   
  98.   
  99. end
  100.  
  101.  
  102. on wrapMedia castNameOfMedia, mediaSprite, wrapperSpritesList, bit_rect
  103.   
  104.   --  repeat with qq = 1 to 2
  105.   cursor 4  -- waiting
  106.   --  set winPartsList = [#tlc: "topLeftCorner",#ts: "panelTop", #trc: "topRightCorner", #rs: "rightSide", #brc: "bottomRightCorner", #bs: "panelBottom", #blc: 17, #ls: 18, #topPanelText: 19, #topPanelMask: 20, #closeButton: "closeNormal", #media: 22]
  107.   --[#tlc: "topLeftCorner",#ts: "topSide", #trc: "topRightCorner", #rs: "rightSide", #brc: "bottomRightCorner", #bs: "bottomSide", #blc: 17, #ls: 18, #topPanelText: 19, #topPanelMask: 20, #closeButton: "closeNormal", #media: "??"]
  108.   
  109.   set author = "kfraser@sfu.ca"
  110.   set copyrightHolder = "⌐1995 Gerri Sinclair & SFU ExCITE Centre"
  111.   
  112.   
  113.   -- Initialize
  114.   
  115.   set mediaSpriteOriginH =  the left of sprite mediaSprite
  116.   set mediaSpriteOriginV =  the top of sprite mediaSprite  
  117.   set mediaCastType = the casttype of the member of sprite mediaSprite
  118.   
  119.   
  120.   set mediaLside = the left of bit_rect
  121.   set mediaTside = the top of bit_rect
  122.   set mediaRside = the right of bit_rect
  123.   set mediaBside = the bottom of bit_rect
  124.   
  125.   set theMediaSpriteHeight = mediaBside - mediaTside
  126.   
  127.   set theCloseButtonHeight = the height of cast "over close up"
  128.   set theCloseButtonWidth = the width of cast "over close up"
  129.   
  130.   -- =-=-=-= 1st: Sprite 2: Top
  131.   
  132.   if #digitalVideo = mediaCastType then
  133.     set currentSpriteNumber = getAt(wrapperSpritesList,2) 
  134.     set pauseButtonSpriteNum = getAt(wrapperSpritesList,9)
  135.     set moreButtonSpriteNum = getAt(wrapperSpritesList,10)
  136.   end if
  137.   
  138.   if #bitmap = mediaCastType then     
  139.     set currentSpriteNumber = getAt(wrapperSpritesList,2) 
  140.     set pauseButtonSpriteNum = getAt(wrapperSpritesList,9)
  141.     set moreButtonSpriteNum = getAt(wrapperSpritesList,10)
  142.   end if
  143.   
  144.   
  145.   set closeButtonSpriteNumber = getAt(wrapperSpritesList,11)
  146.   
  147.   
  148.   set textVoffset = 0 -- down from top of close button
  149.   -- height of top panel - height of close button / 2  
  150.   set textHoffset = 2 -- in from side of close button
  151.   
  152.   -- height of top panel - textVoffset
  153.   set castNameOfSpriteToMove = the name of the member of sprite currentSpriteNumber
  154.   
  155.   set currentCastHeight = the height of cast castNameOfSpriteToMove  
  156.   
  157.   -- POSITION: top side sprite
  158.   spriteBox currentSpriteNumber, mediaLside, mediaTside-currentCastHeight, mediaRside, mediaTside
  159.   
  160.   -- POSITION: mask sprite
  161.   --    spriteBox maskSpriteNumber, mediaLside, mediaTside-currentCastHeight, mediaRside, mediaTside
  162.   
  163.   -- POSITION: more button sprite
  164.   set moreHoffset = 2
  165.   set moreVoffset = 2
  166.   set morebwidth = the width of sprite moreButtonSpriteNum
  167.   set morebheight = the height of sprite moreButtonSpriteNum
  168.   spriteBox moreButtonSpriteNum, mediaRside-moreHoffset-morebwidth, mediaBside-moreVoffset-morebheight, mediaRside-moreHoffset, mediaBside-moreVoffset
  169.   
  170.   
  171.   updatestage
  172.   
  173.   -- POSITION: rewind button sprite
  174.   set rewButtonSpriteNum = 43
  175.   set pauseHoffset = 2
  176.   set pauseVoffset = -38
  177.   set pausebwidth = the width of sprite rewButtonSpriteNum
  178.   set pausebheight = the height of sprite rewButtonSpriteNum
  179.   spriteBox rewButtonSpriteNum mediaLside+pauseHoffset,mediaBside + pauseVoffset, mediaLside+pauseHoffset+pausebwidth,mediaBside+pauseVoffset+pausebheight
  180.   
  181.   --POSITION: pause button
  182.   set pauseHoffset = 18
  183.   set pauseVoffset = -38
  184.   set pausebwidth = the width of sprite pauseButtonSpriteNum
  185.   set pausebheight = the height of sprite pauseButtonSpriteNum
  186.   spriteBox pauseButtonSpriteNum mediaLside+pauseHoffset,mediaBside + pauseVoffset, mediaLside+pauseHoffset+pausebwidth,mediaBside+pauseVoffset+pausebheight
  187.   
  188.   
  189.   -- POSITION: close button sprite
  190.   set closeBtnVoffset = -15 -- down from top of close button
  191.   -- height of top panel - height of close button / 2
  192.   set closeBtnHoffset = 0 -- in from side of close button
  193.   spriteBox closeButtonSpriteNumber, mediaLside + closeBtnHoffset, mediaTside - theCloseButtonHeight-closeBtnVoffset, mediaLside + theCloseButtonWidth + closeBtnHoffset, mediaTside - closeBtnVoffset
  194.   
  195.   updatestage
  196.   set topPanelHeight = currentCastHeight
  197.   
  198.   set totalHeight = theMediaSpriteHeight + currentCastHeight
  199.   
  200.   -- =-=-=-= 2nd: Sprite 6: Bottom Panel
  201.   set currentSpriteNumber = getAt(wrapperSpritesList,6)
  202.   set castNameOfSpriteToMove = the name of cast the castnum of sprite currentSpriteNumber
  203.   set currentCastHeight = the height of cast castNameOfSpriteToMove  
  204.   spriteBox currentSpriteNumber, mediaLside, mediaBside, mediaRside, mediaBside + the height of cast castNameOfSpriteToMove
  205.   
  206.   set totalHeight = totalHeight + currentCastHeight
  207.   set bottomPanelHeight = currentCastHeight
  208.   
  209.   -- =-=-=-= 3rd: Sprite 1: Top Left Corner
  210.   set currentSpriteNumber = getAt(wrapperSpritesList,1)
  211.   set castNameOfSpriteToMove = the name of cast the castnum of sprite currentSpriteNumber
  212.   set currentCastWidth = the width of cast castNameOfSpriteToMove
  213.   set currentCastHeight = the height of cast castNameOfSpriteToMove
  214.   set tLcHeight = currentCastHeight
  215.   set tLcWidth = currentCastWidth
  216.   spriteBox currentSpriteNumber, mediaLside-currentCastWidth, mediaTside-topPanelHeight, mediaLside, mediaTside - topPanelHeight + currentCastHeight
  217.   
  218.   
  219.   updatestage
  220.   
  221.   -- =-=-=-= 4th: Sprite 3: Top Right Corner
  222.   set currentSpriteNumber = getAt(wrapperSpritesList,3)
  223.   set castNameOfSpriteToMove = the name of cast the castnum of sprite currentSpriteNumber
  224.   set currentCastWidth = the width of cast castNameOfSpriteToMove
  225.   set currentCastHeight = the height of cast castNameOfSpriteToMove
  226.   set tRcHeight = currentCastHeight
  227.   set tRcWidth = currentCastWidth
  228.   spriteBox currentSpriteNumber, mediaRside, mediaTside - topPanelHeight, mediaRside+currentCastWidth, mediaTside-topPanelHeight + currentCastHeight
  229.   
  230.   
  231.   -- lapTime("Top Right Corner")  -- DEBUG  
  232.   
  233.   -- =-=-=-= 5th: Sprite 5: Bottom Right Corner
  234.   set currentSpriteNumber = getAt(wrapperSpritesList,5)
  235.   set castNameOfSpriteToMove = the name of cast the castnum of sprite getAt(wrapperSpritesList,5)
  236.   set currentCastWidth = the width of cast castNameOfSpriteToMove
  237.   set currentCastHeight = the height of cast castNameOfSpriteToMove
  238.   set bRcHeight = currentCastHeight
  239.   set bRcWidth = currentCastWidth
  240.   spriteBox currentSpriteNumber, mediaRside, mediaBside + bottomPanelHeight - currentCastHeight, mediaRside+currentCastWidth, mediaBside+bottomPanelHeight
  241.   
  242.   
  243.   -- lapTime("Bottom Right Corner")  -- DEBUG  
  244.   
  245.   -- =-=-=-= 6th: Sprite 7: Bottom Left Corner
  246.   set currentSpriteNumber = getAt(wrapperSpritesList,7)
  247.   set castNameOfSpriteToMove = the name of cast the castnum of sprite getAt(wrapperSpritesList,5)
  248.   set currentCastWidth = the width of cast castNameOfSpriteToMove
  249.   set currentCastHeight = the height of cast castNameOfSpriteToMove
  250.   set bLcHeight = currentCastHeight
  251.   set bLcWidth = currentCastWidth
  252.   spriteBox currentSpriteNumber, mediaLside - currentCastWidth, mediaBside + bottomPanelHeight - currentCastHeight, mediaLside, mediaBside + bottomPanelHeight
  253.   
  254.   -- here now
  255.   updatestage
  256.   
  257.   -- lapTime("Bottom Left Corner")  -- DEBUG  
  258.   
  259.   -- =-=-=-= 7th: Sprite 8: Left Side
  260.   set currentSpriteNumber = getAt(wrapperSpritesList,8)
  261.   set castNameOfSpriteToMove = the name of cast the castnum of sprite getAt(wrapperSpritesList,5)
  262.   set currentCastWidth = the width of cast castNameOfSpriteToMove
  263.   set currentCastHeight = the height of cast castNameOfSpriteToMove
  264.   spriteBox currentSpriteNumber, mediaLside - currentCastWidth, mediaTside - topPanelHeight + tLcHeight, mediaLside, mediaBside + bottomPanelHeight - bLcHeight
  265.   
  266.   
  267.   -- lapTime("Left Side")  -- DEBUG  
  268.   
  269.   -- =-=-=-= 8th: Sprite 4: Right Side
  270.   set currentSpriteNumber = getAt(wrapperSpritesList,4)
  271.   set castNameOfSpriteToMove = the name of cast the castnum of sprite getAt(wrapperSpritesList,5)
  272.   set currentCastWidth = the width of cast castNameOfSpriteToMove
  273.   set currentCastHeight = the height of cast castNameOfSpriteToMove  
  274.   spriteBox currentSpriteNumber, mediaRside, mediaTside - topPanelHeight + tRcHeight, mediaRside + currentCastWidth, mediaBside + bottomPanelHeight - bRcHeight
  275.   
  276.   
  277.   cursor -1 -- normal cursor
  278.   
  279.   updatestage -- debug something wierd about this updatestage
  280.   
  281.   
  282. end
  283.  
  284. on incrementSpriteList listToProcess
  285.   set castNameOfSpriteToMove = the name of cast the castnum of sprite getAt(listToProcess,1)
  286.   set currentCastHeight = the height of cast castNameOfSpriteToMove
  287.   deleteAt listToProcess, 1 -- another one bites the dust
  288.   return [listToProcess,castNameOfSpriteToMove,currentCastHeight]  
  289. end
  290.  
  291. on lapTime label
  292.   global startTime, timeSummary
  293.   if voidP(startTime) then 
  294.     put the ticks into startTime
  295.   else
  296.     put the ticks - 1 - startTime && label & return after timeSummary
  297.     put the ticks - 1 into startTime
  298.   end if
  299.   --return ""
  300. end
  301.  
  302. on timeSummary
  303.   global timeSummary
  304.   put empty into timeSummary
  305.   put 0 into totalTicks
  306.   repeat with x = 1 to the number of lines in timeSummary
  307.     set totalTicks = totalTicks + value(word 1 of line x of timeSummary)
  308.   end repeat
  309.   return timeSummary&return & totalTicks&&"total"
  310. end